<template>
	<view class="mainbgc" v-if="pageShow">
		<header-top :messageInfo="{typeFlag:true,message:'客户排名'}">
			<view class="rightmsg" slot="rightmsg">
				<view class="rightmsg_content flexright">
					<text @click="show=true">筛选</text>
					<view class="selecticon"></view>
				</view>
			</view>
		</header-top>
		<!-- 筛选弹出层 -->
		<u-popup :show="show" @close="show=false" mode="bottom" :round="10">
			<view class="titletext flexcenter margin_top textcenter">筛选</view>
			<view class="mainpadding sxtext">
				<view class="flexleft margin_top">
					<view class="sxwidth margin_right">行业：</view>
					<view class="sxinput" @click="popshow(1)">
						<input type="text" placeholder="请选择行业" disabled="" v-model="hy.name">
					</view>
				</view>
				<view class="flexleft margin_top">
					<view class="sxwidth margin_right">关键字：</view>
					<view class="sxinput">
						<input type="text" placeholder="请输入关键字" v-model="keywords">
					</view>
				</view>
				<!-- <view class="flexleft margin_top">
					<view class="sxwidth margin_right">套餐：</view>
					<view class="sxinput" @click="popshow(2)">
						<input type="text" placeholder="请选择套餐" disabled="" v-model="tc.name">
					</view>
				</view>
				<view class="flexleft margin_top">
					<view class="sxwidth margin_right">客户类型：</view>
					<view class="sxinput" @click="popshow(3)">
						<input type="text" placeholder="请选择客户类型" disabled="" v-model="khlx.name">
					</view>
				</view>
				<view class="flexleft margin_top">
					<view class="sxwidth margin_right">范围：</view>
					<view class="sxinput" @click="popshow(4)">
						<input type="text" placeholder="请选择范围" disabled="" v-model="fw.name">
					</view>
				</view> -->
				<view class="sxbtn" @click="close(1)">确认</view>
			</view>
		</u-popup>
		<view class="mainpadding2">
			<view class="content_top flexbetween">
				<view class="margin_top">
					共计：<text style="color: #3476fe;">{{list.total}}</text>
				</view>
			</view>
			<view class="itembox mainpadding radius margin_top  ffffff" v-for="(item,index) in list.data" :key="item.id"
				@click="jumpurldetail(item.id)">
				<view class="lable">{{item.intention.name}}</view>
				<view v-show="index==0" class="num berone"></view>
				<view v-show="index==1" class="num bertwo"></view>
				<view v-show="index==2" class="num berthree"></view>
				<view v-show="index>=3" class="num">{{index+1}}</view>
				<view class="right-content">
					<!-- <view class="strongtext flexleft">{{item.name || ""}}<text class="smalltext">（{{item.gongsi || ""}}）</text></view> -->
					<view class="strongtext flexleft">{{item.name || ""}}</view>
					<view class="yihang textleft margin_top" style="width: 200rpx;">
						姓名：{{item.khname || ""}}
					</view>
					<view class="flexbetween margin_top">
						<view class="yihang textleft" style="width: 200rpx;">
							行业：{{item.industry.name || ""}}
						</view>
						<view class="yihang textright width300">
							经营区域:{{item.jyqy || ""}}
						</view>
					</view>
					<view class="margin_top" @click.stop="openlocation(item)">
						<view class="flexleft">
							<view class="yihang" style="width: 450rpx;">
								地址：{{item.cityinfo}}/{{item.address_detail || ""}}
							</view>
							<view class="addressicon"></view>
						</view>
					</view>
					<view class="margin_top">
						<text>套餐：{{item.thaliinfo.thali_name}}</text>
						
					</view>
					<view class="flexleft margin_top" @click.stop="phone(item.mobile)">电话：{{item.tel}}
						<view class="callphone"></view>
					</view>
					<view class="margin_top">
						规模等级：{{item.scalelevel.name || ""}}
					</view>
					<view class="margin_top">
						到期天数：<text style="color: #ff0000;">{{item.end_days || 0}}</text>
					</view>
				</view>
			</view>
		</view>
		<!-- 行业 -->
		<u-picker :show="hyshow" :columns="hycolumns" keyName="name" @confirm="hyconfirm" @cancel="hyshow=false">
		</u-picker>
		<!-- 套餐 -->
		<!-- <u-picker :show="tcshow" :columns="tccolumns" keyName="title" @confirm="tcconfirm" @cancel="tcshow=false">
		</u-picker> -->
		<!-- 客户类型 -->
		<!-- <u-picker :show="khlxshow" :columns="khlxcolumns" keyName="name" @confirm="khlxconfirm"
			@cancel="khlxshow=false"></u-picker> -->
		<!-- 范围 -->
		<!-- <u-picker :show="fwshow" :columns="fwcolumns" keyName="name" @confirm="fwconfirm" @cancel="fwshow=false">
		</u-picker> -->
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				show: false,
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				// 行业
				hyshow: false,
				hycolumns: [],
				hy: {
					name: "",
					id: "",
				},
				keywords: "", //关键字
				pageShow: false
				// 套餐
				// tcshow: false,
				// tccolumns: [],
				// tc: {
				// 	name: "",
				// 	id: "",
				// },
				// 客户类型
				// khlxshow: false,
				// khlxcolumns: [],
				// khlx: {
				// 	name: "",
				// 	id: "",
				// },
				// // 范围
				// fwshow: false,
				// fwcolumns: [],
				// fw: {
				// 	name: "",
				// 	id: "",
				// },
			}
		},
		onShow() {
			this.getsx()
			this.init()
		},
		methods: {
			// getsx() {
			// 	httpRequest.request('/appapi/staff/customers/category', 'POST', {}).then(res => {
			// 		this.hycolumns.push(res.data.hangye)
			// 		this.fwcolumns.push(res.data.fanwei)
			// 		this.tccolumns.push(res.data.taocan)
			// 		this.khlxcolumns.push(res.data.kehufenlei)
			// 	})
			// },
			// popupclose() {
			// 	this.popup = false
			// },
			getsx() {
				httpRequest.request('/employeesapi/index/getindustry', 'GET', {}).then(res => {
					this.hycolumns.push(res.data)
				})
			},
			// 重要客户排名列表数据
			init(isPage, page) {
				let _this = this
				httpRequest.request('/employeesapi/shop/shopList', 'GET', {
					page: page || 1,
					limit: _this.limit,
					start_time: "", //开始时间
					end_time: "", //结束时间
					intention_id: "", //意向度 id
					industry_id: this.hy.id, //行业id
					thali_id: "", //套餐id
					keywords: this.keywords, //关键字
					thali_sort: 1, //客户排名 0不排名1排名
					yxe_sort: "", //客户营销额排名
					// hangye: this.hy.id, //行业id
					// taocan: this.tc.id, //行业id
					// type: this.khlx.id, //行业id
					// fanwei: this.fw.id, //行业id
				}, false, false, true).then(res => {
					if (res.code == 1) {
						// res.data.data.forEach(item=>{
						// 	let address = item.dianpu.split("/")
						// 	item.dianpu = address.join("")
						// })
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							_this.list = resList
							_this.list.data = resList.data;
						}
						_this.pageShow = true
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			jumpurldetail(id) {
				uni.navigateTo({
					url: '/pages/customerdetail/customerdetail?id=' + id
				})
			},
			popshow(value) {
				this.show = false
				if (value == 1) {
					this.hyshow = true
				} else if (value == 2) {
					this.tcshow = true
				} else if (value == 3) {
					this.khlxshow = true
				} else if (value == 4) {
					this.fwshow = true
				}
			},
			hyconfirm(e) {
				this.hyshow = false
				this.show = true
				this.hy.name = e.value[0].name
				this.hy.id = e.value[0].id
			},
			// tcconfirm(e) {
			// 	this.tcshow = false
			// 	this.show = true
			// 	this.tc.name = e.value[0].title
			// 	this.tc.id = e.value[0].id
			// },
			// khlxconfirm(e) {
			// 	this.khlxshow = false
			// 	this.show = true
			// 	this.khlx.name = e.value[0].name
			// 	this.khlx.id = e.value[0].id
			// },
			// fwconfirm(e) {
			// 	this.fwshow = false
			// 	this.show = true
			// 	this.fw.name = e.value[0].name
			// 	this.fw.id = e.value[0].id
			// },
			close(value) {
				this.show = false
				this.init()
			},
			openlocation(item) {
				uni.openLocation({
					latitude: Number(item.lat), //即将传到高德或腾讯地图的终点纬度  必须是数值，字符串无效
					longitude: Number(item.lng), //即将传到高德或腾讯地图的终点经度  必须是数值，字符串无效
					name: item.address, //即将传到高德或腾讯地图的店铺名称
					address: item.dianpu + item.address, //即将传到高德或腾讯地图的详细地址
					scale: 18
				})
			},
			// 打电话
			phone(p) {
				uni.makePhoneCall({
					phoneNumber: p.toString()
				}).catch((e) => {
					// console.log(e)  //用catch(e)来捕获错误{makePhoneCall:fail cancel}
				})
			}
		}
	}
</script>
<!-- 筛选弹出层内容 -->
<style lang="scss">
	.content_top {
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 800;
		color: #999999;
		flex-wrap: wrap;
		padding: 0 30rpx;
	}
	.currentsx {
		flex-wrap: wrap;
	}

	.itemcurrent {
		padding: 10rpx 20rpx;
		border-radius: 50rpx;
		border: #3476fe 1rpx solid;
	}

	.btn {
		border-radius: 50rpx;
	}
</style>
<style lang="scss" scoped>
	.itembox {
		position: relative;
		display: flex;
		align-items: flex-start;
		justify-content: left;
	}

	.lable {
		position: absolute;
		right: 0;
		top: 0;
		padding: 10rpx 5rpx;
		border-bottom-left-radius: 20rpx;
		border-top-right-radius: 20rpx;
		border: 1rpx solid #3476fe;
		font-size: 24rpx;
		font-weight: 500;
		color: #3476fe;
	}

	.num {
		width: 52rpx;
		min-width: 52rpx;
		height: 68rpx;
		margin-right: 30rpx;
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: 800;
		color: #333333;
	}

	.berone {
		background-image: url('@/static/imags/mainrank/num1.png');
		background-size: 100% 100%;
	}

	.bertwo {
		background-image: url('@/static/imags/mainrank/num2.png');
		background-size: 100% 100%;
	}

	.berthree {
		background-image: url('@/static/imags/mainrank/num3.png');
		background-size: 100% 100%;
	}

	.right-content {
		width: 100%;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	.strongtext {
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 800;
		color: #333333;
	}

	.smalltext {
		font-size: 26rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
	}

	// 筛选样式开始
	.sxbtn {
		width: 100%;
		margin-top: 50rpx;
		padding: 20rpx 0;
		background-color: #3476fe;
		border-radius: 10rpx;
		text-align: center;
		color: #fff;
		font-size: 32rpx;
	}

	.sxtext {
		font-size: 32rpx;
		color: #333;
		font-weight: bold;
	}

	.sxwidth {
		width: 250rpx;
	}

	.sxinput {
		width: 100%;

		input {
			width: 100%;
		}
	}

	// 结束
</style>